blob: 54cf9ac070dce00d2cc5c0dc762c6fa9e033780c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
---
import { type CollectionEntry, getCollection, render } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
import { renderGemtextToHtml } from '../../renderGemtextToHtml';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.id },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
const post = Astro.props;
const Content = post.filePath?.endsWith('.gmi')
? renderGemtextToHtml(post.body ?? '', post.data.title)
: (await render(post)).Content;
---
<BlogPost
title={post.data.title}
description={post.data.description}
pubDate={post.data.pubDate ?? new Date(post.id)}
updatedDate={post.data.updatedDate}
>
{ post.filePath?.endsWith('.gmi') ? <Fragment set:html={Content}></Fragment> : <Content />}
</BlogPost>
|